FileBrowser::FileBrowser(const QString &filter, QWidget *parent, const char *name)
 : QListBox(parent, name)
{
 nameFilter = filter;
 setDir(QDir::currentDirPath());
 connect(this, SIGNAL(highlighted(int)), this, SLOT(itemHighlighted(int)));
 connect(this, SIGNAL(selected(int)), this, SLOT(itemSelected(int)));
}

void FileBrowser::setDir(const QString &path)
{
    QDir dir(path, nameFilter, QDir::DirsFirst);
    dir.setMatchAllDirs(true);
    if (!dir.isReadable())
        return;
    clear();

    QStringList entries = dir.entryList();
    QStringList::ConstIterator it = entries.constBegin();
    while (it != entries.constEnd()) {
        if (*it != ".")
            insertItem(*it);
        ++it;
    }
    basePath = dir.canonicalPath();
}
